"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LogFileUtil_1 = require("./LogFileUtil");
const Log_Level_Names = ["debug", "log", "info", "warn", "error"];
class Logger {
    static formatNow() {
        let date = new Date(); //后端返回的时间戳是秒
        return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + ":" + date.getMilliseconds();
    }
    static getLogPreKey(nowLevel) {
        let str = "[" + Logger.formatNow() + "] " + Logger.tag + " ["
            + Log_Level_Names[nowLevel] + "] ";
        return str;
    }
    static debug(...params) {
        if (Logger.LEVEL > 0 /* DEBUG */) {
            return;
        }
        let str = this.getLogPreKey(0 /* DEBUG */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.debug(fileStr);
        if (this.Terminal_Log) {
            console.debug("%c" + str, this.Log_Color_Config[0 /* DEBUG */], ...params);
        }
        else {
            console.debug(str, ...params);
        }
    }
    static log(...params) {
        if (Logger.LEVEL > 1 /* LOG */) {
            return;
        }
        let str = this.getLogPreKey(1 /* LOG */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.log(fileStr);
        if (this.Terminal_Log) {
            console.log("%c" + str, this.Log_Color_Config[0 /* DEBUG */], ...params);
        }
        else {
            console.log(str, ...params);
        }
    }
    static info(...params) {
        if (Logger.LEVEL > 2 /* INFO */) {
            return;
        }
        let str = this.getLogPreKey(2 /* INFO */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.info(fileStr);
        if (this.Terminal_Log) {
            console.info("%c" + str, this.Log_Color_Config[0 /* DEBUG */], ...params);
        }
        else {
            console.info(str, ...params);
        }
    }
    static warn(...params) {
        if (Logger.LEVEL > 3 /* WARN */) {
            return;
        }
        let str = this.getLogPreKey(3 /* WARN */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.warn(fileStr);
        if (this.Terminal_Log) {
            console.warn("%c" + str, this.Log_Color_Config[0 /* DEBUG */], ...params);
        }
        else {
            console.warn(str, ...params);
        }
    }
    static error(...params) {
        if (Logger.LEVEL > 4 /* ERROR */) {
            return;
        }
        let str = this.getLogPreKey(4 /* ERROR */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.error(fileStr);
        if (this.Terminal_Log) {
            console.error("%c" + str, this.Log_Color_Config[0 /* DEBUG */], ...params);
        }
        else {
            console.error(str, ...params);
        }
    }
    static clientLog(...params) {
        let str = this.getLogPreKey(1 /* LOG */);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogErrorFileUtil.clientLog(fileStr);
        // if (this.Terminal_Log) {
        //     console.log("%c" + str, this.Log_Color_Config[LOG_LEVEL_TYPES.DEBUG], ...params)
        // } else {
        //     console.log(str, ...params)
        // }
    }
}
exports.Logger = Logger;
Logger.tag = "[HaoJslog]"; //可以设置当前游戏的前缀
Logger.LEVEL = 0 /* DEBUG */; //当前Logger等级
Logger.Log_Color_Config = [
    "color:#290;font-size:20px;",
    "color:#000;font-size:21px;",
    "color:#09f;font-size:22px;",
    "color:#f90;font-size:23px;",
    "color:#f00;font-size:25px;",
];
Logger.Terminal_Log = false;
